package com.ys.disease.controller;

import com.ys.disease.annotation.AnonymousAccess;
import com.ys.disease.base.result.ResponseResult;
import com.ys.disease.service.TestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: 测试控制层
 * @PROJECT_NAME: ys-scms-servers
 * @DESCRIPTION:
 * @USER: lin
 * @DATE: 2024/10/6 20:38
 */
@Slf4j
@RestController
@RequestMapping("/test")
public class testController {

    @Autowired
    private  PasswordEncoder passwordEncoder;


    private TestService testService;
    //测试接口
    /**
     * 健康检测接口
     * @return ok
     */
    @AnonymousAccess
    @ApiOperation(value = "健康检测")
    @GetMapping("/yz")
    public ResponseResult yz(String user , String password, String Key) {
        //请求时需要携带用户名、密码、唯一key
        //1.先在数据库中找到user和key
         Boolean verifyResult = testService.verifyUserKey(user, password, Key);

        //2.再用springSecurity自带的passwordEncoder验证password是否宇数据库中的password一致
        return ResponseResult.success("");
    }
}
